from google.appengine.ext import db 
from  google.appengine.ext import users

class Chat(db.Model):
  creator = db.UserProperty()
  peopleinchat = db.ListProperty()
  chatName= db.StringProperty()
  message = db.TextProperty()
 
 
class createchat(webapp.RequestHandler):


class givebackchat(webapp.RequestHandler):
	def get(self):
		chatName = self.request.get("chatName")
		query = Chat.all()
		query.filter('chatName =', chatName)
		chat = query.get()
		self.response.out.write(chat.message)

class updatechat (webapp.RequestHandler):
	def get(self):
		message = self.request.get("message" )
		chatName = self.request.get("chatName")
		query = Chat.all()
		query.filter('chatName =', chatName)
		chat = query.get()
		chat.message = chat.message+ message 
	    chat.put()
class getListofChats(webapp.RequestHandler):
	def get(self):
		query = Chat.gql('WHERE peopleinchat = :1', users.get_current_user().email)
		chats = query.fetch()
		for chat in chats
		self.response.out.write(chat.chatName +"/n")

		
